package com.boding.power.utils;

import java.security.Principal;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import com.boding.power.model.Users;


/**
 * 获取shiro 封装的用户信息
 * 
 * @author giegie
 * @date 2016年4月28日
 * @description
 * 
 */
public class UserUtil {
	public static Users getUser() {
		Subject subject = SecurityUtils.getSubject();
		String principal = (String) subject.getPrincipal();
		if (principal != null) {
			String sql = "select * from users where username = ?";
			Users users = Users.dao.findFirst(sql, principal);
			if (users != null) {
				return users;
			}
		}
		return null;
	}
}
